'use strict';

const BaseController = require('../base');

class TravelOrderItemController extends BaseController {
  static get serviceName() {
    return 'business.travelOrderItem';
  }

  // 获取旅游订单的订单项列表
  async travelOrderItems() {
    const { ctx } = this;
    const { travelOrderId } = ctx.params;
    const result = await this.service.getItemsByTravelOrder(travelOrderId);
    ctx.success(result);
  }

  // 批量创建旅游订单项
  async batchCreate() {
    const { ctx } = this;
    const data = ctx.request.body;
    const result = await this.service.batchCreate(data);
    ctx.success(result);
  }

  // 获取旅游订单项详情（包含旅游产品信息）
  async detail() {
    const { ctx } = this;
    const { id } = ctx.params;
    const result = await this.service.getDetailWithTravel(id);
    ctx.success(result);
  }

  // 获取旅游订单项统计信息
  async statistics() {
    const { ctx } = this;
    const { travelOrderId } = ctx.params;
    const result = await this.service.getTravelOrderStatistics(travelOrderId);
    ctx.success(result);
  }
}

module.exports = TravelOrderItemController; 